import React, { Component } from 'react';
class Son extends Component {
  handerClick =(params) => {
    this.props.handerFatherClick(this.state.text);
  }
  state = {
    text:'🍉'
  }
  render(){
    return (
      <div>
      <h1>{this.props.children}</h1>
      <button onClick={this.handerClick}>传值给父组件</button>
    </div>
    )
  }
}
class App extends Component {
  handerFatherClick=(params) => {
     this.setState({
      text:params,
    }) 
  }
  state = {
    msg:'🐂',
    text:'',
  }

  
  render() {
    return (
    
        <div className="father">
            <h1>我是父级</h1>
            <h2>收到子组件传来的的值 {this.state.text}</h2>
            <Son handerFatherClick = {this.handerFatherClick}></Son>
            
        </div>
        
    
    );
  }
}

export default App;
